package com.data.config;
//
//import com.baomidou.mybatisplus.MybatisConfiguration;
//import com.baomidou.mybatisplus.MybatisXMLLanguageDriver;
//import com.baomidou.mybatisplus.entity.GlobalConfiguration;
//import com.baomidou.mybatisplus.enums.IdType;
//import com.baomidou.mybatisplus.mapper.LogicSqlInjector;
//import com.baomidou.mybatisplus.plugins.OptimisticLockerInterceptor;
//import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
//import com.baomidou.mybatisplus.spring.MybatisSqlSessionFactoryBean;
//import com.baomidou.mybatisplus.spring.boot.starter.MybatisPlusProperties;
//import org.apache.ibatis.plugin.Interceptor;
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.apache.ibatis.type.JdbcType;
//import org.springframework.boot.context.properties.EnableConfigurationProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;

//@Configuration
//@EnableConfigurationProperties(value = {MybatisPlusProperties.class})
public class MybatisPlusConfigO {
//
//    private MybatisPlusProperties mybatisPlusProperties;
//
//    public MybatisPlusConfigO(MybatisPlusProperties mybatisPlusProperties) {
//        this.mybatisPlusProperties = mybatisPlusProperties;
//    }
//
//    /**
//     * 数据源
//     * @return
//     */
////    @ConfigurationProperties(prefix = "spring.druid")
////    @Bean(initMethod = "init",destroyMethod = "close")
////    public DruidDataSource dataSource(){
////        DruidDataSource druidDataSource = new DruidDataSource();
////        List<Filter> list = new ArrayList<>();
////        list.add(statFilter());
////        druidDataSource.setProxyFilters(list);
////        return druidDataSource;
////    }
//
//    /**
//     * 打印慢日志的Filter
//     */
////    @Bean
////    public Filter statFilter(){
////        StatFilter statFilter = new StatFilter();
////        statFilter.setSlowSqlMillis(1000);
////        statFilter.setLogSlowSql(true);
////        statFilter.setMergeSql(true);
////        return statFilter;
////    }
//
//    /**
//     * Druid 监控
//     */
////    @Bean
////    public ServletRegistrationBean servletRegistrationBean(){
////        return new ServletRegistrationBean(new StatViewServlet(),"/druid/*");
////    }
//
//    @Bean("mybatisSqlSession")
//    public SqlSessionFactory sqlSessionFactory(DataSource dataSource, GlobalConfiguration globalConfiguration) throws Exception {
//        MybatisSqlSessionFactoryBean sqlSessionFactory = new MybatisSqlSessionFactoryBean();
//        sqlSessionFactory.setDataSource(dataSource);
//        sqlSessionFactory.setTypeAliasesPackage(mybatisPlusProperties.getTypeAliasesPackage());
//        sqlSessionFactory.setTypeEnumsPackage(mybatisPlusProperties.getTypeEnumsPackage());
//        MybatisConfiguration configuration = new MybatisConfiguration();
//        configuration.setDefaultScriptingLanguage(MybatisXMLLanguageDriver.class);
//        configuration.setJdbcTypeForNull(JdbcType.NULL);
//        sqlSessionFactory.setConfiguration(configuration);
//        sqlSessionFactory.setPlugins(new Interceptor[]{
//                new PaginationInterceptor(),
////                new PerformanceInterceptor(),
//                new OptimisticLockerInterceptor()
//        });
//        sqlSessionFactory.setGlobalConfig(globalConfiguration);
//        return sqlSessionFactory.getObject();
//    }
//
//    @Bean
//    public GlobalConfiguration globalConfiguration() {
//        GlobalConfiguration conf = new GlobalConfiguration(new LogicSqlInjector());
//        conf.setIdType(IdType.AUTO.getKey());
//        return conf;
//    }
//
}
